package www.openteam.com.presenter.business;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.InsertStatus;
import www.openteam.com.contract.business.InsertCustomInfoContract;
import www.openteam.com.model.business.InsertCustomInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.NewBuildFragment;

/**
 * Created by kylin on 2016/10/20.
 */

public class InsertCustomInfoPresenter extends BasePresenter<NewBuildFragment> implements
        InsertCustomInfoContract.InsertCustomInfoPresenter {


    @Override
    public HashMap<String, IModel> getiModelMap() {

        return loadModelMap(new InsertCustomInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("InsertCustomInfo", models[0]);
        return hashMap;
    }

    @Override
    public void insertCustomInfo(String code, String name, String type, String paytime, String moneytype, String SendAddress, String connecter, String BusinessMan, String CreditNumb, String cTel) {

        if (!getIView().checkNull()) {
            ((InsertCustomInfoModel) getiModelMap().get("InsertCustomInfo"))
                    .insertCustomInfo(code, name, type, paytime, moneytype, SendAddress,
                            connecter, BusinessMan, CreditNumb, cTel, new InsertCustomInfoModel.InsertCustomInfoOnListener() {
                                @Override
                                public void insertCISuccess(InsertStatus insertStatus) {
                                    getIView().insertCIData(insertStatus);
                                }

                                @Override
                                public void insertCIFail(Throwable throwable) {

                                    getIView().hideCIData(throwable);
                                }
                            });

        }
    }
}
